//  Copyright (c) Microsoft Corporation.  All Rights Reserved.

using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.IdentityModel.Selectors;

namespace EAI.SAML
{
    public class EAISamlOneTimeUse : EAISamlCondition
    {
        public EAISamlOneTimeUse()
        {
        }

        public EAISamlOneTimeUse(XmlReader reader, EAISamlSerializer serializer, SecurityTokenSerializer keyInfoSerializer, SecurityTokenResolver outOfBandTokenResolver)
        {
            this.ReadXml(reader, serializer, keyInfoSerializer, outOfBandTokenResolver);
        }

        public override void MakeReadOnly()
        {
            return;
        }

        public override void ReadXml(XmlReader reader, EAISamlSerializer serializer, SecurityTokenSerializer keyInfoSerializer, SecurityTokenResolver outOfBandTokenResolver)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            // This is an empty element. So just read the element.
            if (reader.IsEmptyElement)
            {
                reader.MoveToContent();
                reader.Read();
                return;
            }

            reader.MoveToContent();
            reader.Read();
            reader.ReadEndElement();
        }

        public override void WriteXml(XmlWriter writer, SecurityTokenSerializer tokenSerializer)
        {
            if (writer == null)
                throw new ArgumentNullException("writer");

            writer.WriteStartElement(EAISamlConstants.OneTimeUse, EAISamlConstants.Namespace);
            writer.WriteEndElement();
        }
    }
}
